import request from '@/static/js/popular.js'

/**
 * 上传base64到服务端  换取文件地址
 * @param {Object} base64
 */
export function uploadBase64(base64) {
	return request.ajaxPost('/busLocalFile/upldBase64Str', {
		base64Str: base64
	})
}

/**
 * 查询厂家
 */
export function searchFactory() {
	return request.ajaxPost('/sysDept/getPage', {
		pageNum: 0,
		pageSize: 9999,
		isHideHospital: 0,
		operationGroup: 1,
		state: 0,
	})
}
/**
 * 查询厂家代表
 */
export function searchFactoryPerson(deptId) {

	return request.ajaxPost('/sysManager/getPage', {
		pageNum: 0,
		pageSize: 9999,
		deptId: deptId,
		states: '1,0,-1'
	})
}
/**
 * 获取【院区】列表
 */
export function getHospitalAreaList() {
	return request.ajaxPost('/sysDept/getList', {
		pageNum: 0,
		pageSize: 9999,
		state: 1
	})
}
/**
 * 获取【院区】下的部门列表
 */
export function getHospitalAreaDepartmentList(hospitalId) {
	return request.ajaxPost('/sysDept/getPage', {
		pageNum: 0,
		pageSize: 9999,
		isHideHospital: 1,
		parentId: hospitalId,
		state: 1
	})
}

/**
 * 获取指定部门数据
 * 
 */
export function getDepartmentData(id) {

	return request.ajaxPost('/sysDept/get', { id })
}

/**
 * 获取指定 用户数据
 */
export function getUserData(userId) {

	return request.ajaxPost('/sysManager/get', { id: userId })
}


/**
 * 上传文件
 */
export function upLoad(filePath,data,fn){ 
	uni.uploadFile({
		url: 'https://jinyiweikeji.com/ywt/busLocalFile/upload',
		filePath: filePath, 
		header:{
			token: uni.getStorageSync('token') || ''
		},
		formData: data,
		name: 'file',
		success:fn
	});
}